UMAP
SCpubr::do_DotPlot(PV_filt,features=list('Microglia'=AB_markers_curated$Microglia),
group.by = "Organoids") +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

SCpubr::do_DotPlot(PV_filt, features=list('Epithelial'=AB_markers$`Epithelial Cells`,
'Radial Glia'=AB_markers$`Radial Glia`,
'NPCs'=AB_markers$NPCs,
'Neurons'=AB_markers$Neurons,
'Exc. neurons'=AB_markers$`Excitatory neurons`,
'Inh. neurons'=AB_markers$`Inhibitory neurons`,
'Interneurons'=AB_markers$Interneurons,
'Cortical neurons'=AB_markers$`Cortical neurons`,
'Mesenchymal'=AB_markers$`Mesenchymal cells`,
'Oligodendrocytes'=AB_markers$Oligodendrocytes,
'Astrocytes'=AB_markers$Astrocytes,
'Microglia'=AB_markers$Microglia,
'Cilia'=AB_markers$Cilia,
'ChP'=AB_markers$ChP),
group.by = "seurat_clusters")+
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

Idents(PV_filt) <- PV_filt$seurat_clusters
identity <- c('0'='NPC',
'1'='Cortical neurons',
'2'='NPC',
'3'='NPC',
'4'='Mesenchymal/ChP (Cilia-associated)',
'5'='NPC',
'6'='Microglia',
'7'='Microglia')
PV_filt <- RenameIdents(object = PV_filt, identity)
PV_filt@meta.data$identity <- Idents(PV_filt)
table(PV_filt$identity)
##
## NPC Cortical neurons
## 79480 22070
## Mesenchymal/ChP (Cilia-associated) Microglia
## 5588 282
PV_filt$identity <- factor(PV_filt$identity, levels=unique(PV_filt$identity))
DimPlot(PV_filt, reduction = 'umap', group.by='identity', cols = RColorBrewer::brewer.pal(7,'Accent')[c(1,2,3,6)])

DimPlot(PV_filt, reduction = 'umap', group.by='identity', split.by = 'Organoids', cols = RColorBrewer::brewer.pal(7,'Accent')[c(1,2,3,6)])

DimPlot(PV_filt, reduction = 'umap', group.by='identity', split.by = 'cell.line', cols = RColorBrewer::brewer.pal(7,'Accent')[c(1,2,3,6)])

table(PV_filt$cell.line,PV_filt$identity)
##
## NPC Mesenchymal/ChP (Cilia-associated) Cortical neurons Microglia
## MSN38 38690 2603 11712 26
## WTC11 40790 2985 10358 256
FeaturePlot(PV_filt,features = 'Cluster1',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu"))) +
ggtitle('Microglia markers')

FeaturePlot(PV_filt,features = 'Cluster2',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu"))) +
ggtitle('Mesenchymal/ChP markers')

FeaturePlot(PV_filt,features = 'Cluster3',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu"))) +
ggtitle('Neuron markers')

FeaturePlot(PV_filt,features = 'Cluster4',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu"))) +
ggtitle('NPC markers')

FeaturePlot(PV_filt,features = 'AIF1',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu")))

FeaturePlot(PV_filt,features = 'TTR',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu")))

FeaturePlot(PV_filt,features = 'STMN2',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu")))

FeaturePlot(PV_filt,features = 'VIM',reduction = 'umap') +
scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu")))

prop <- data.frame('CO'=prop.table(table(PV_filt$identity,PV_filt$Organoids)[,1]),'COiMg'=prop.table(table(PV_filt$identity,PV_filt$Organoids)[,2]))
df <- data.frame('Cell Type'=rep(rownames(prop),2),'Organoids'=c(rep('CO',4),rep('COiMg',4)),'Percentage'=round(c(prop[,1],prop[,2])*100,2))
ggplot(df, aes(x = Organoids, y = Percentage, fill = `Cell.Type`))+
geom_bar(stat = "identity")+
geom_text(aes(label = paste(Percentage,"%")), position = position_stack(vjust = 0.5)) +
scale_fill_manual(values=RColorBrewer::brewer.pal(7,'Accent')[c(2,6,3,1)]) +
theme_minimal()

SCpubr::do_DotPlot(PV_filt, features=list('Microglia'=AB_markers$Microglia,'Cilia'=AB_markers$Cilia,
'ChP'=AB_markers$ChP),group.by = 'Organoids')+
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

SCpubr::do_DotPlot(PV_filt, features=list('COiMg DEGs'=coimg_degs[[2]][coimg_degs[[2]] %in% rownames(PV_filt)]),group.by = 'identity')+
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
